package com.changcheng.project.ble_upgrade_recordinfo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.changcheng.framework.aspectj.lang.annotation.Log;
import com.changcheng.framework.aspectj.lang.enums.BusinessType;
import com.changcheng.project.ble_upgrade_recordinfo.domain.BleUpgradeRecordinfo;
import com.changcheng.project.ble_upgrade_recordinfo.service.IBleUpgradeRecordinfoService;
import com.changcheng.framework.web.controller.BaseController;
import com.changcheng.framework.web.domain.AjaxResult;
import com.changcheng.common.utils.poi.ExcelUtil;
import com.changcheng.framework.web.page.TableDataInfo;

/**
 * 升级记录表Controller
 * 
 * @author dazhi
 * @date 2021-03-10
 */
@Controller
@RequestMapping("/ble_upgrade_recordinfo/ble_upgrade_recordinfo")
public class BleUpgradeRecordinfoController extends BaseController
{
    private String prefix = "ble_upgrade_recordinfo/ble_upgrade_recordinfo";

    @Autowired
    private IBleUpgradeRecordinfoService bleUpgradeRecordinfoService;

    @RequiresPermissions("ble_upgrade_recordinfo:ble_upgrade_recordinfo:view")
    @GetMapping()
    public String ble_upgrade_recordinfo()
    {
        return prefix + "/ble_upgrade_recordinfo";
    }

    /**
     * 查询升级记录表列表
     */
    @RequiresPermissions("ble_upgrade_recordinfo:ble_upgrade_recordinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BleUpgradeRecordinfo bleUpgradeRecordinfo)
    {
        startPage();
        List<BleUpgradeRecordinfo> list = bleUpgradeRecordinfoService.selectBleUpgradeRecordinfoList(bleUpgradeRecordinfo);
        return getDataTable(list);
    }

    /**
     * 导出升级记录表列表
     */
    @RequiresPermissions("ble_upgrade_recordinfo:ble_upgrade_recordinfo:export")
    @Log(title = "升级记录表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BleUpgradeRecordinfo bleUpgradeRecordinfo)
    {
        List<BleUpgradeRecordinfo> list = bleUpgradeRecordinfoService.selectBleUpgradeRecordinfoList(bleUpgradeRecordinfo);
        ExcelUtil<BleUpgradeRecordinfo> util = new ExcelUtil<BleUpgradeRecordinfo>(BleUpgradeRecordinfo.class);
        return util.exportExcel(list, "ble_upgrade_recordinfo");
    }

    /**
     * 新增升级记录表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存升级记录表
     */
    @RequiresPermissions("ble_upgrade_recordinfo:ble_upgrade_recordinfo:add")
    @Log(title = "升级记录表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BleUpgradeRecordinfo bleUpgradeRecordinfo)
    {
        return toAjax(bleUpgradeRecordinfoService.insertBleUpgradeRecordinfo(bleUpgradeRecordinfo));
    }

    /**
     * 修改升级记录表
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BleUpgradeRecordinfo bleUpgradeRecordinfo = bleUpgradeRecordinfoService.selectBleUpgradeRecordinfoById(id);
        mmap.put("bleUpgradeRecordinfo", bleUpgradeRecordinfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存升级记录表
     */
    @RequiresPermissions("ble_upgrade_recordinfo:ble_upgrade_recordinfo:edit")
    @Log(title = "升级记录表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BleUpgradeRecordinfo bleUpgradeRecordinfo)
    {
        return toAjax(bleUpgradeRecordinfoService.updateBleUpgradeRecordinfo(bleUpgradeRecordinfo));
    }

    /**
     * 删除升级记录表
     */
    @RequiresPermissions("ble_upgrade_recordinfo:ble_upgrade_recordinfo:remove")
    @Log(title = "升级记录表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bleUpgradeRecordinfoService.deleteBleUpgradeRecordinfoByIds(ids));
    }
}
